<?php
include_once("../../configure/configure.php");		//--> global var
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("Smarty.class.php");					//--> out template

include_once("impl/MenuGroupImpl.php");				//--> Menu group class
include_once("impl/MenuImpl.php");				//--> Menu group class

require_once(dirname(__FILE__) . "/../controlHeader.php");				//--> system control header
require_once(dirname(__FILE__) . "/../controlOperate.php");				//-->


$menuGroupImpl 	= new MenuGroupImpl(DB_TAG_SYSTEM);		//--> Menu group instance
$menuImpl 		= new MenuImpl(DB_TAG_SYSTEM);		//--> Menu instance



if(isset($_GET['id']) && !empty($_GET['id'])){
	$id = $_GET['id'];

	if($gid == $id){
		$error_message = 'invalid delete menu group.';
	}else if(count($menuImpl->lists(" WHERE groupid=$id", 1, 1, '')) > 0) {
		$error_message = "can't delete the user group, because that have user above the user group.";
	}else{
		$isReturn = $menuGroupImpl->delete($id);
		if($isReturn)
			$error_message = 'delete group successfully.';
		else 
			$error_message = 'delete group fail.';
	}
}

echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";

//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
